#!/usr/env/bin python
# -*- coding: utf-8 -*-

# @Time    : 2020-10-23 9:48 上午
# @Author  : yangdy
# @File    : LC目标和
# @Software: PyCharmCE
from tools.my_methods import *


class Solution:
    def findTargetSumWays(self, nums: List[int], S: int) -> int:

        self.ans = 0
        sums = []



        def dfs(nums, s, i=0, a=0):
            if i >= len(nums):
                if a == s:
                    self.ans += 1
                return
            dfs(nums, s, i+1, a+nums[i])
            dfs(nums, s, i+1, a-nums[i])
            return
        dfs(nums, S)
        return self.ans


questions = [
    ([1, 1, 1, 1, 1], 3),
]

work(questions, lambda q: Solution().findTargetSumWays(q[0], q[1]))
